
/*

Design Pattern Automation Toolkit.
Application to create applications with emphasis on Design patterns.
And support for round trip engineering.
Copyright (C) 2004 Vineeth Neelakant. nvineeth@gmail.com

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

*/
using System;using BusinessLayer;using InfoClasses;using dpatoolkit.UILayer;
using DesignPatternDefinitions;
using System.Data;
using System.Collections;

namespace BusinessLayer
{
	/// <summary>
	/// Concrete Class implementing IComponent
	/// </summary>
	public class DPComponent :IProjectComponent
	{
		DataSet dataset;
		DataRow dataRow;
		public DPComponent(DataRow dr)
		{
//			compName=comp;
			this.dataset=dr.Table.DataSet;
			this.dataRow=dr;
		}
		#region IProjectComponent Members

		public string ComponentAuthor {
			get {
				return (string) this.dataRow[SchemaNames.ComponentAuthor];
			}
			set{}
		}

		public string ComponentName {
			get {
				return (string) this.dataRow[SchemaNames.ComponentName];
			}set{}
		}

		public string ComponentSummary{
			get{return (string) this.dataRow[SchemaNames.Summary]; }
			set{}
		}

		public ArrayList Classes {
			get {

				ArrayList ClassList = new ArrayList();
				DataTable ClassTable = this.dataset.Tables[SchemaNames.Classes];
				DataRow[] Clrows = ClassTable.Select(SchemaNames.ComponentName+"='"+this.ComponentName+"'");

				foreach(DataRow row in Clrows) {
					ClassList.Add( new DPClass((string)row[SchemaNames.ComponentName],
						(string)row[SchemaNames.ClassName],this.dataset));
					}
				return ClassList;
			}
			set {
				// TODO:  Add DPComponent.Classes setter implementation
			}
		}

		public string Project {
			get {
				// TODO:  Add DPComponent.Project getter implementation
				return null;
			}set{}
		}

		public IClass GetClass(string className)
		{
			return new DPClass(this.ComponentName,className,this.dataset);
		}

		public System.Drawing.Size Dimension
		{
			get
			{
				DataTable table = this.dataset.Tables[SchemaNames.ComponentUIDetails];
				DataRow row = table.Rows.Find(this.ComponentName);
			
				if( row !=null)
				{
					return new System.Drawing.Size((int)row[SchemaNames.Width],
									(int)row[SchemaNames.Height]);
				}
				
				return new System.Drawing.Size(800,800);
			}
			set
			{
				//TODO,,,
			}
		}
		#endregion
	}
}
